<template>
	<view class="container">
		<view class="title">
			请选择您要查看的学生
		</view>
		<view class="selectContainer" v-if="user_info">
			<view class="selectItem" 
			@click="selectUser(index)"
			v-for="(item,index) in user_info" :key='index'>
				<view class="avatar">
					<image :src="item.avatar" mode=""></image>
				</view>
				<view class="info">
					<view class="name">
						{{item.nickname}}
					</view>
					<view class="desc">
						学生证号{{item.student_no}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user_info:[],
			}
		},
		created() {
			uni.getStorage({
				key: 'user_info',
				success: (res) => {
					if(Array.isArray(res.data)){
						this.user_info = res.data;
					}else{
						this.user_info.push(res.data);
					}
					
					},
				})
		},
		methods:{
			selectUser(index){
				uni.setStorage({
					key: 'user_info',
					data: this.user_info[index],
					success: function() {
						console.log('success');
					}
				});
				uni.switchTab({
					url: '../index/index?source=1'
				});
			},
		}
		}
</script>

<style scoped lang="scss">
	.title {
		font-size: 15px;
		font-family: SourceHanSansCN-Medium, SourceHanSansCN;
		font-weight: 500;
		color: #333333;
		line-height: 15px;
		margin: 19px 0 28px 35rpx;
	}
	.selectContainer{
		background-color: #FFFFFF;
		box-sizing: border-box;
		border-radius: 8px;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.selectItem{
			width: 680rpx;
			height: 220rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 20px 0px #E9EBF6;
			border-radius: 8px;
			font-family: SourceHanSansCN-Normal, SourceHanSansCN;
			display: flex;
			flex-direction: row;
			padding: 27px 33px;
			box-sizing: border-box;
			align-items: center;
			.avatar{
				width: 56px;
				height: 56px;
				background: #EDF0FF;
				border-radius: 50%;
				margin-right: 11px;
				image{
					display: block;
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}
			.nikename{
				font-size: 18px;
				font-weight: 700;
				color: #333333;
				line-height: 27px;
			}
			.desc{
				font-size: 13px;
				color: #999999;
				line-height: 13px;
				margin-top: 8px;
			}
		}
		.selectItem:nth-child(2){
			margin-top: 20px;
		}
	}
</style>
